package com.nancy.aop.aop.jdk;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * All rights Reserved, Designed By guangfeng.zhou
 *
 * @version V1.0
 * @Project: learning-demo
 * @Package: com.nancy.aop.jdk
 * @Description: (用一句话描述该文件做什么)
 * @author: guangfeng.zhou
 * @date: 2017/12/4 14:31
 */
public class AopHandler implements InvocationHandler {

    private Logger log = LoggerFactory.getLogger(getClass()) ;

    private Object target ;

    public AopHandler(Object target){
        this.target = target ;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        log.info("Transactional begin.. ");
        Object obj = method.invoke(target, args) ;
        log.info("Transactional end.. ");

        return obj;
    }
}
